//
//  SpecialCarTableViewCell.m
//  小汽车
//
//  Created by 杜远洋 on 14-12-30.
//  Copyright (c) 2014年 蓝欧科技. All rights reserved.
//

#import "SpecialCarTableViewCell.h"
#import "Masonry.h"
@implementation SpecialCarTableViewCell

- (void)dealloc
{
    [_dateLabel release];
    [_titleLabel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       
 
        self.contentView.backgroundColor = [UIColor clearColor];

        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, CELL_WIDTH - 20, CELL_HEIGHT - 10)];
        [self.titleLabel setBackgroundColor:[UIColor clearColor]];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(CELL_WIDTH/4 *3, CELL_HEIGHT/3 * 2 , CELL_WIDTH/4, CELL_HEIGHT/3)];
        [self.dateLabel setBackgroundColor:[UIColor clearColor]];
        [self.dateLabel setFont:[UIFont systemFontOfSize:15]];
        [self.dateLabel setTextColor:[UIColor colorWithRed:105/255.0f green:105/255.0f blue:105/255.0f alpha:1]];

        [self.contentView addSubview:self.dateLabel];
        [_dateLabel release];
        
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    NSUserDefaults *myNight = [NSUserDefaults standardUserDefaults];
    if ([[myNight objectForKey:@"night"] isEqualToString:@"0"]) {
        [self.titleLabel setTextColor:[UIColor blackColor]];
    }
    else
    {
        [self.titleLabel setTextColor:[UIColor whiteColor]];
        
    }
    
    if ([[myNight objectForKey:@"night"] isEqualToString:@"0"]) {
        [self.dateLabel setTextColor:[UIColor colorWithRed:105/255.0f green:105/255.0f blue:105/255.0f alpha:1]];
    }
    else
    {
        [self.dateLabel setTextColor:[UIColor colorWithRed:65/255.0f green:105/255.0f blue:225/255.0f alpha:1]];
        
    }

    
    
    __block UITableViewCell *weakSelf = self;
    
//    self.titleLabel.frame = CGRectMake(CELL_WIDTH / 72 * 2, CELL_WIDTH / 72, CELL_WIDTH - 20, CELL_HEIGHT / 2);
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@(weakSelf.frame.size.width / 72 * 2));
        make.top.mas_equalTo(@(weakSelf.frame.size.width / 72));
        make.width.equalTo(weakSelf.mas_width).with.offset(- 20);
        make.height.mas_equalTo(@(weakSelf.frame.size.height/2));
    }];
    
    
//    self.dateLabel.frame = CGRectMake(CELL_WIDTH / 4 * 3, CELL_HEIGHT / 3 * 2, CELL_WIDTH / 24 * 7, CELL_HEIGHT / 3);
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(weakSelf.frame.size.height / 3 * 2, weakSelf.frame.size.width / 20 * 14,  weakSelf.frame.size.height / 10,  weakSelf.frame.size.width / 75));
    }];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
